import React, {useState, useEffect} from 'react';
import { SSL_OP_SSLEAY_080_CLIENT_DH_BUG } from 'constants';

class MyCount extends React.Component {
    state = {
        count : 0,
    }
    
    componentDidMount() {
        setInterval(() => {
            this.setInterval({count: this.state.count + 1}, 1000)
        })
    }

    render () {
        return <span>{this.state.count}</span>
    }
}

function MycountFunc() {
    const [count, setCount] = useState(0)

    useEffect(() => {
        const interval = setInterval(() => {
            setCount(count + 1)
        }, 1000)
        return () => clearInterval(interval)
    })
    return <span>{this.state.count}</span>
}

export default MycountFunc;